package com.none.staff.view.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.List;

public class GuideAdapter extends PagerAdapter {

    Context context;
    List<ImageView> imageViewList;

    public GuideAdapter(Context context, List<ImageView> imageViewList) {
        this.context = context;
        this.imageViewList = imageViewList;
    }

    @Override
    public int getCount() {
        return imageViewList.size();
    }

    @Override
    public int getItemPosition(@NonNull Object object) {
        return super.getItemPosition(object);
    }

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object o) {
        return view == imageViewList.get(Integer.parseInt(o.toString()));
    }

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
        container.removeView(imageViewList.get(position));
    }

    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup container, int position) {
        ImageView view = imageViewList.get(position);
        view.setScaleType(ImageView.ScaleType.CENTER_CROP);
        container.addView(view);
        return position;

    }
}
